<!DOCTYPE html>
<html>
<head>
  <meta charset="utf-8">
  

  
  <title>关于容灾，前端能够做什么 | 在路上</title>
  <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
  <meta name="description" content="应用场景存在轮询的AJAX或者JSONP跨域请求的Web应用。 比如我们有两台服务器，分别是a.com和a-bk.com，默认的轮询请求使用a.com； 当a.com由于某种原因无法访问，需要按照一种事先约定的机制，将后续请求指向到备用服务器。 同时当主服务器正常时，立即切换到主服务器。 现实项目在我们的应用中，JSONP轮询的频率是每十秒一次。由于移动机房经常性的故障，导致客户长时间不能正常访问">
<meta name="keywords" content="JavaScript">
<meta property="og:type" content="article">
<meta property="og:title" content="关于容灾，前端能够做什么">
<meta property="og:url" content="http://yoursite.com/2012/03/28/关于容灾，前端能够做什么/index.html">
<meta property="og:site_name" content="在路上">
<meta property="og:description" content="应用场景存在轮询的AJAX或者JSONP跨域请求的Web应用。 比如我们有两台服务器，分别是a.com和a-bk.com，默认的轮询请求使用a.com； 当a.com由于某种原因无法访问，需要按照一种事先约定的机制，将后续请求指向到备用服务器。 同时当主服务器正常时，立即切换到主服务器。 现实项目在我们的应用中，JSONP轮询的频率是每十秒一次。由于移动机房经常性的故障，导致客户长时间不能正常访问">
<meta property="og:locale" content="zh-CN">
<meta property="og:updated_time" content="2018-03-26T11:35:06.702Z">
<meta name="twitter:card" content="summary">
<meta name="twitter:title" content="关于容灾，前端能够做什么">
<meta name="twitter:description" content="应用场景存在轮询的AJAX或者JSONP跨域请求的Web应用。 比如我们有两台服务器，分别是a.com和a-bk.com，默认的轮询请求使用a.com； 当a.com由于某种原因无法访问，需要按照一种事先约定的机制，将后续请求指向到备用服务器。 同时当主服务器正常时，立即切换到主服务器。 现实项目在我们的应用中，JSONP轮询的频率是每十秒一次。由于移动机房经常性的故障，导致客户长时间不能正常访问">
  
    <link rel="alternate" href="/atom.xml" title="在路上" type="application/atom+xml">
  
  
    <link rel="icon" href="/favicon.png">
  
  
    <link href="//fonts.googleapis.com/css?family=Source+Code+Pro" rel="stylesheet" type="text/css">
  
  <link rel="stylesheet" href="/css/style.css">
</head>

<body>
  <div id="container">
    <div id="wrap">
      <header id="header">
  <div id="banner"></div>
  <div id="header-outer" class="outer">
    <div id="header-title" class="inner">
      <h1 id="logo-wrap">
        <a href="/" id="logo">在路上</a>
      </h1>
      
        <h2 id="subtitle-wrap">
          <a href="/" id="subtitle">一位崇尚价值投资的 Web 开发者</a>
        </h2>
      
    </div>
    <div id="header-inner" class="inner">
      <nav id="main-nav">
        <a id="main-nav-toggle" class="nav-icon"></a>
        
          <a class="main-nav-link" href="/">Home</a>
        
          <a class="main-nav-link" href="/archives">Archives</a>
        
      </nav>
      <nav id="sub-nav">
        
          <a id="nav-rss-link" class="nav-icon" href="/atom.xml" title="RSS Feed"></a>
        
        <a id="nav-search-btn" class="nav-icon" title="搜索"></a>
      </nav>
      <div id="search-form-wrap">
        <form action="//google.com/search" method="get" accept-charset="UTF-8" class="search-form"><input type="search" name="q" class="search-form-input" placeholder="Search"><button type="submit" class="search-form-submit">&#xF002;</button><input type="hidden" name="sitesearch" value="http://yoursite.com"></form>
      </div>
    </div>
  </div>
</header>
      <div class="outer">
        <section id="main"><article id="post-关于容灾，前端能够做什么" class="article article-type-post" itemscope itemprop="blogPost">
  <div class="article-meta">
    <a href="/2012/03/28/关于容灾，前端能够做什么/" class="article-date">
  <time datetime="2012-03-27T16:00:00.000Z" itemprop="datePublished">2012-03-28</time>
</a>
    
  </div>
  <div class="article-inner">
    
    
      <header class="article-header">
        
  
    <h1 class="article-title" itemprop="name">
      关于容灾，前端能够做什么
    </h1>
  

      </header>
    
    <div class="article-entry" itemprop="articleBody">
      
        <h2 id="应用场景"><a href="#应用场景" class="headerlink" title="应用场景"></a>应用场景</h2><p>存在轮询的AJAX或者JSONP跨域请求的Web应用。</p>
<p>比如我们有两台服务器，分别是a.com和a-bk.com，默认的轮询请求使用a.com；</p>
<p>当a.com由于某种原因无法访问，需要按照一种事先约定的机制，将后续请求指向到备用服务器。</p>
<p>同时当主服务器正常时，立即切换到主服务器。</p>
<h2 id="现实项目"><a href="#现实项目" class="headerlink" title="现实项目"></a>现实项目</h2><p>在我们的应用中，JSONP轮询的频率是每十秒一次。由于移动机房经常性的故障，导致客户长时间不能正常访问。</p>
<p>于是客户经常向我们报障，试想如果此时，前端能够将用户的后续访问切换到我们的电信服务器，那该多好啊！</p>
<p>虽然响应会慢一些，但是至少整个系统处于可用状态。</p>
<h2 id="容灾机制"><a href="#容灾机制" class="headerlink" title="容灾机制"></a>容灾机制</h2><p>经过和同事们的一番讨论最后确定我们的容灾机制：</p>
<p>连续两次请求没有及时应答则认定当前服务器不可用，切换到备用服务器；</p>
<p>同时发起一个定时器，每55秒检测主服务器是否可用（访问主服务器上的一张43b的图片），一旦可用，立刻切换到主服务器。</p>
<h2 id="实现逻辑"><a href="#实现逻辑" class="headerlink" title="实现逻辑"></a>实现逻辑</h2><p>确定好容灾机制以后，剩下的就是编码了。</p>
<p>不过编码之前其实还有一个隐藏的重大问题，那就是我们如何确定这个请求是否超时？</p>
<p>因为我们的跨域JSONP请求都是使用script tag，而且需要兼容IE 6,自然没有什么类似的ontimeout事件去检测。</p>
<p>那我们就只有自己动手来处理了。</p>
<p>对于单个请求超时的判断，我们可以在主函数启动时设置一个状态量为false，回调函数中修改这个值为true。</p>
<p>由于需要尽量避免修改原函数逻辑，这里用到了 <code>AOP</code> 技术，详细参见<a href="http://xugaofan.github.com/javascript/2012/03/18/AOP-in-JavaScript/" target="_blank" rel="noopener">这里</a></p>
<h3 id="方案一"><a href="#方案一" class="headerlink" title="方案一"></a>方案一</h3><p>每一次发起JSONP请求后，开启一个setTimeout 8秒后去检测状态量是否被修改（变量由回调函数修改），依此判断响应成功与否。</p>
<h3 id="方案二"><a href="#方案二" class="headerlink" title="方案二"></a>方案二</h3><p>建立一个对象，给每一次请求标记ID，将其使用的服务器地址和响应结果记录下来；</p>
<p>在第N次请求发起之前，判断第N-2次和N-1次请求是否使用相同的服务器，如果是，当这两次请求都没有及时响应时切换到备用服务器。</p>
<h3 id="比较结果"><a href="#比较结果" class="headerlink" title="比较结果"></a>比较结果</h3><p>方案一对每次请求都在下一次轮询之前就决定它是成功还是失败。我在生产中设置的值是6.5秒，但发现许多客户经常在主服务器和备用服务器上来回切换。</p>
<p>方案二的好处在于，首先没有发起额外的setTimeout来监测请求成功是否响应，其次对于每一次请求方案二的超时时间实际是一个动态的值。</p>
<p>对比下就知道方案一对每个请求的超时容忍度都是相同的6.5秒，最大也只能是10秒，而方案二第N-2次的超时容忍时间是20秒，第N-1次是10秒。</p>
<p>所以严格意义上来讲，方案二更宽容也更加合理。</p>
<h2 id="编码实现"><a href="#编码实现" class="headerlink" title="编码实现"></a>编码实现</h2><figure class="highlight javascript"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br><span class="line">17</span><br><span class="line">18</span><br><span class="line">19</span><br><span class="line">20</span><br><span class="line">21</span><br><span class="line">22</span><br><span class="line">23</span><br><span class="line">24</span><br><span class="line">25</span><br><span class="line">26</span><br><span class="line">27</span><br><span class="line">28</span><br><span class="line">29</span><br><span class="line">30</span><br><span class="line">31</span><br><span class="line">32</span><br><span class="line">33</span><br><span class="line">34</span><br><span class="line">35</span><br><span class="line">36</span><br><span class="line">37</span><br><span class="line">38</span><br><span class="line">39</span><br><span class="line">40</span><br><span class="line">41</span><br><span class="line">42</span><br><span class="line">43</span><br><span class="line">44</span><br><span class="line">45</span><br><span class="line">46</span><br><span class="line">47</span><br><span class="line">48</span><br><span class="line">49</span><br><span class="line">50</span><br><span class="line">51</span><br><span class="line">52</span><br><span class="line">53</span><br><span class="line">54</span><br><span class="line">55</span><br><span class="line">56</span><br><span class="line">57</span><br><span class="line">58</span><br><span class="line">59</span><br><span class="line">60</span><br><span class="line">61</span><br><span class="line">62</span><br><span class="line">63</span><br><span class="line">64</span><br><span class="line">65</span><br><span class="line">66</span><br><span class="line">67</span><br><span class="line">68</span><br><span class="line">69</span><br><span class="line">70</span><br><span class="line">71</span><br><span class="line">72</span><br><span class="line">73</span><br><span class="line">74</span><br><span class="line">75</span><br><span class="line">76</span><br><span class="line">77</span><br><span class="line">78</span><br><span class="line">79</span><br><span class="line">80</span><br><span class="line">81</span><br><span class="line">82</span><br><span class="line">83</span><br><span class="line">84</span><br><span class="line">85</span><br><span class="line">86</span><br><span class="line">87</span><br><span class="line">88</span><br><span class="line">89</span><br><span class="line">90</span><br><span class="line">91</span><br><span class="line">92</span><br><span class="line">93</span><br><span class="line">94</span><br><span class="line">95</span><br><span class="line">96</span><br><span class="line">97</span><br><span class="line">98</span><br></pre></td><td class="code"><pre><span class="line"><span class="comment">/**</span></span><br><span class="line"><span class="comment">* @description 网络模块</span></span><br><span class="line"><span class="comment">* @property &#123;Number&#125; DETECT_CYCLE 切换到备用服务器后，监测主域名的周期，单位为秒，周期长度最好不要设置为10的倍数，便于调试观察</span></span><br><span class="line"><span class="comment">*/</span></span><br><span class="line">_.net = &#123; <span class="attr">DETECT_CYCLE</span>:<span class="number">55</span> &#125;;</span><br><span class="line"><span class="comment">/**</span></span><br><span class="line"><span class="comment">* @description 为跨域请求函数注入容灾备份机制，需要将原函数的请求服务器地址改成_.net['funcname_current_server'];</span></span><br><span class="line"><span class="comment">* 实现原理：使用对象存储每一次请求使用的服务器地址和请求结果，然后在每一次请求之前，判断前两次使用相同服务器的请求是否都不成功。</span></span><br><span class="line"><span class="comment">* 如果都不成功表明连续两次请求失败则切换到备用服务器</span></span><br><span class="line"><span class="comment">* @param &#123;Object&#125; entry 入口函数&#123;context:执行环境,name:函数名称&#125;</span></span><br><span class="line"><span class="comment">* @param &#123;Object&#125; exit 回调函数&#123;context:执行环境,name:函数名称&#125;</span></span><br><span class="line"><span class="comment">* @param &#123;Object&#125; settings 服务端配置&#123;server:主域地址,backupServer:备选服务器地址，数组，长度为0则不启用容灾机制,serverImg:监测主域名可用的图片&#125;</span></span><br><span class="line"><span class="comment">* @param &#123;Function&#125; forward 动态判断是否在入口函数继续执行注入的容灾机制</span></span><br><span class="line"><span class="comment">* @usage 参见/user/js/map.js</span></span><br><span class="line"><span class="comment">* @dependacy &#123;Function&#125; _.inject</span></span><br><span class="line"><span class="comment">*/</span></span><br><span class="line">_.net.backup = <span class="function"><span class="keyword">function</span>(<span class="params">entry,exit,settings,forward</span>)</span>&#123;</span><br><span class="line">    <span class="keyword">var</span> server = settings.server,currentServer = entry.name + <span class="string">'_current_server'</span>;</span><br><span class="line">    _.net[currentServer] = server;</span><br><span class="line">    <span class="comment">//没有备用地址则不启动容灾备份机制</span></span><br><span class="line">    <span class="keyword">if</span>(!settings.backupServer || !_.isArray(settings.backupServer) || !settings.backupServer.length) <span class="keyword">return</span>;</span><br><span class="line">    <span class="keyword">var</span> interval = entry.name + <span class="string">'_interval'</span>,<span class="comment">//切换到备用以后发起定时器key_name</span></span><br><span class="line">        total = entry.name + <span class="string">'_total'</span>,<span class="comment">//总的请求次数key_name</span></span><br><span class="line">        status = entry.name + <span class="string">'_status'</span>,<span class="comment">//维护各次请求的地址和请求结果key_name</span></span><br><span class="line">        serverAvailable = entry.name + <span class="string">'_server_available'</span>;<span class="comment">//表明当前主服务器是否可用的key_name</span></span><br><span class="line">    <span class="comment">//主服务器可用时立即切换，并重置对应的变量</span></span><br><span class="line">    <span class="keyword">var</span> resetServer = <span class="function"><span class="keyword">function</span>(<span class="params"></span>)</span>&#123;</span><br><span class="line">        _.net[serverAvailable] = <span class="literal">true</span>;</span><br><span class="line">        _.net[currentServer] = server;</span><br><span class="line">        clearInterval(_.net[interval]);</span><br><span class="line">    &#125;;</span><br><span class="line">    <span class="comment">//筛选服务器算法，如果当前使用主服务器则切换到备用，如果已经是备用，有多个备用时则切换到下一个备用，只有一个备用是切换到主服务器</span></span><br><span class="line">    <span class="keyword">var</span> selectServer = <span class="function"><span class="keyword">function</span>(<span class="params"></span>)</span>&#123;</span><br><span class="line">        <span class="keyword">if</span>(_.net[currentServer] == server)&#123;</span><br><span class="line">            <span class="keyword">return</span> settings.backupServer[<span class="number">0</span>];</span><br><span class="line">        &#125;<span class="keyword">else</span>&#123;</span><br><span class="line">            <span class="keyword">var</span> len = settings.backupServer.length;</span><br><span class="line">            <span class="keyword">if</span>(len ==<span class="number">1</span>)</span><br><span class="line">                <span class="keyword">return</span> server;</span><br><span class="line">            <span class="keyword">var</span> index = _.indexOf(settings.backupServer,_.net[currentServer]);</span><br><span class="line">            <span class="keyword">return</span> settings.backupServer[index+<span class="number">1</span>] || settings.backupServer[<span class="number">0</span>];</span><br><span class="line">        &#125;</span><br><span class="line">    &#125;;</span><br><span class="line">    _.net[serverAvailable] = <span class="literal">true</span>;</span><br><span class="line">    _.net[interval] = <span class="literal">null</span>;</span><br><span class="line">    _.net[total] = <span class="number">0</span>;</span><br><span class="line">    _.net[status] = &#123;&#125;;<span class="comment">//格式：&#123;1:['http://a.net/',true], 2:['http://a.net/']&#125;</span></span><br><span class="line">    entry.start = <span class="function"><span class="keyword">function</span>(<span class="params"></span>)</span>&#123;</span><br><span class="line">        <span class="keyword">if</span>(<span class="keyword">typeof</span> forward == <span class="string">'function'</span>)&#123;</span><br><span class="line">            <span class="keyword">if</span>(!forward())<span class="keyword">return</span>;</span><br><span class="line">        &#125;</span><br><span class="line">        _.net[total] += <span class="number">1</span>;</span><br><span class="line">        <span class="keyword">var</span> count = _.net[total];</span><br><span class="line">        <span class="comment">//存储当此请求使用的服务器地址和响应结果</span></span><br><span class="line">        _.net[status][count<span class="number">-1</span>] = [];</span><br><span class="line">        <span class="keyword">if</span>(count &gt; <span class="number">2</span>)&#123;</span><br><span class="line">            <span class="keyword">var</span> prev = _.net[status][count<span class="number">-2</span>], prevPrev = _.net[status][count<span class="number">-3</span>];</span><br><span class="line">            <span class="comment">//上两次请求使用同一个服务器且都失败了，则切换服务器</span></span><br><span class="line">            <span class="keyword">if</span>(prev[<span class="number">0</span>] == prevPrev[<span class="number">0</span>] &amp;&amp; !prev[<span class="number">1</span>] &amp;&amp; !prevPrev[<span class="number">1</span>])&#123;</span><br><span class="line">                <span class="keyword">var</span> usingServer = _.net[currentServer] == server, old = _.net[currentServer];</span><br><span class="line">                <span class="keyword">if</span>(usingServer)&#123;</span><br><span class="line">                    _.net[interval] = setInterval(<span class="function"><span class="keyword">function</span>(<span class="params"></span>)</span>&#123;</span><br><span class="line">                        <span class="keyword">var</span> img = <span class="keyword">new</span> Image();</span><br><span class="line">                        img.onload = resetServer;</span><br><span class="line">                        img.src = settings.serverImg + (settings.serverImg.indexOf(<span class="string">'?'</span>)&gt;<span class="number">-1</span>?<span class="string">'&amp;'</span>:<span class="string">'?'</span>) + <span class="string">'t='</span> + <span class="keyword">new</span> <span class="built_in">Date</span>().getTime();</span><br><span class="line">                    &#125;, _.net.DETECT_CYCLE*<span class="number">1000</span>);</span><br><span class="line">                &#125;</span><br><span class="line">                <span class="comment">//如果只有一个备用服务器且备用不可用则立即切换到tbo</span></span><br><span class="line">                <span class="keyword">if</span>(!usingServer &amp;&amp; settings.backupServer.length==<span class="number">1</span>)&#123;</span><br><span class="line">                    resetServer();</span><br><span class="line">                &#125;<span class="keyword">else</span>&#123;</span><br><span class="line">                    _.net[currentServer] = selectServer(_.net[currentServer]);</span><br><span class="line">                    _.net[serverAvailable] = _.net[currentServer] == server;</span><br><span class="line">                &#125;</span><br><span class="line">                <span class="keyword">if</span>(settings.errorHandler)&#123;</span><br><span class="line">                    settings.errorHandler(old,_.net[currentServer]);</span><br><span class="line">                &#125;</span><br><span class="line">            &#125;<span class="keyword">else</span>&#123;</span><br><span class="line">                <span class="comment">//如果备用服务器一直正常，那么需要一直检测主域名是否可用，如果可用立即切换到主域名</span></span><br><span class="line">                <span class="keyword">if</span>(_.net[currentServer] != server)&#123;</span><br><span class="line">                    <span class="keyword">if</span>(_.net[serverAvailable])&#123;</span><br><span class="line">                        resetServer();</span><br><span class="line">                    &#125;</span><br><span class="line">                &#125;</span><br><span class="line">            &#125;</span><br><span class="line">            <span class="comment">//删除冗余信息，保证数组长度为2</span></span><br><span class="line">            <span class="keyword">delete</span> _.net[status][count<span class="number">-3</span>];</span><br><span class="line">        &#125;</span><br><span class="line">        <span class="comment">//记录当此请求使用的服务器地址</span></span><br><span class="line">        _.net[status][count<span class="number">-1</span>][<span class="number">0</span>] = _.net[currentServer];</span><br><span class="line">    &#125;;</span><br><span class="line">    exit.start = <span class="function"><span class="keyword">function</span>(<span class="params"></span>)</span>&#123;</span><br><span class="line">        <span class="comment">//标记本次请求成功，不成功的请求数组长度为1</span></span><br><span class="line">        _.net[status][_.net[total]<span class="number">-1</span>][<span class="number">1</span>] = <span class="literal">true</span>;</span><br><span class="line">    &#125;;</span><br><span class="line">    _.inject(entry);</span><br><span class="line">    _.inject(exit);</span><br><span class="line">&#125;;</span><br></pre></td></tr></table></figure>

      
    </div>
    <footer class="article-footer">
      <a data-url="http://yoursite.com/2012/03/28/关于容灾，前端能够做什么/" data-id="cjf865ufz001h8wp1ai95x4pd" class="article-share-link">Share</a>
      
      
  <ul class="article-tag-list"><li class="article-tag-list-item"><a class="article-tag-list-link" href="/tags/JavaScript/">JavaScript</a></li></ul>

    </footer>
  </div>
  
    
<nav id="article-nav">
  
    <a href="/2012/07/27/A-Cross-Domain-Practice/" id="article-nav-newer" class="article-nav-link-wrap">
      <strong class="article-nav-caption">Newer</strong>
      <div class="article-nav-title">
        
          一次跨域实践
        
      </div>
    </a>
  
  
    <a href="/2012/03/18/AOP-in-JavaScript/" id="article-nav-older" class="article-nav-link-wrap">
      <strong class="article-nav-caption">Older</strong>
      <div class="article-nav-title">AOP in JavaScript</div>
    </a>
  
</nav>

  
</article>

</section>
        
          <aside id="sidebar">
  
    

  
    
  <div class="widget-wrap">
    <h3 class="widget-title">标签</h3>
    <div class="widget">
      <ul class="tag-list"><li class="tag-list-item"><a class="tag-list-link" href="/tags/JavaScript/">JavaScript</a></li><li class="tag-list-item"><a class="tag-list-link" href="/tags/JavaScript-解析器/">JavaScript,解析器</a></li><li class="tag-list-item"><a class="tag-list-link" href="/tags/React/">React</a></li><li class="tag-list-item"><a class="tag-list-link" href="/tags/Redux/">Redux</a></li><li class="tag-list-item"><a class="tag-list-link" href="/tags/SlimerJS/">SlimerJS</a></li><li class="tag-list-item"><a class="tag-list-link" href="/tags/代码管理/">代码管理</a></li><li class="tag-list-item"><a class="tag-list-link" href="/tags/持续集成/">持续集成</a></li></ul>
    </div>
  </div>


  
    
  <div class="widget-wrap">
    <h3 class="widget-title">标签云</h3>
    <div class="widget tagcloud">
      <a href="/tags/JavaScript/" style="font-size: 20px;">JavaScript</a> <a href="/tags/JavaScript-解析器/" style="font-size: 10px;">JavaScript,解析器</a> <a href="/tags/React/" style="font-size: 16.67px;">React</a> <a href="/tags/Redux/" style="font-size: 10px;">Redux</a> <a href="/tags/SlimerJS/" style="font-size: 10px;">SlimerJS</a> <a href="/tags/代码管理/" style="font-size: 10px;">代码管理</a> <a href="/tags/持续集成/" style="font-size: 13.33px;">持续集成</a>
    </div>
  </div>

  
    
  <div class="widget-wrap">
    <h3 class="widget-title">归档</h3>
    <div class="widget">
      <ul class="archive-list"><li class="archive-list-item"><a class="archive-list-link" href="/archives/2016/09/">九月 2016</a></li><li class="archive-list-item"><a class="archive-list-link" href="/archives/2016/07/">七月 2016</a></li><li class="archive-list-item"><a class="archive-list-link" href="/archives/2016/06/">六月 2016</a></li><li class="archive-list-item"><a class="archive-list-link" href="/archives/2016/03/">三月 2016</a></li><li class="archive-list-item"><a class="archive-list-link" href="/archives/2016/02/">二月 2016</a></li><li class="archive-list-item"><a class="archive-list-link" href="/archives/2015/12/">十二月 2015</a></li><li class="archive-list-item"><a class="archive-list-link" href="/archives/2015/06/">六月 2015</a></li><li class="archive-list-item"><a class="archive-list-link" href="/archives/2015/05/">五月 2015</a></li><li class="archive-list-item"><a class="archive-list-link" href="/archives/2015/04/">四月 2015</a></li><li class="archive-list-item"><a class="archive-list-link" href="/archives/2014/07/">七月 2014</a></li><li class="archive-list-item"><a class="archive-list-link" href="/archives/2014/06/">六月 2014</a></li><li class="archive-list-item"><a class="archive-list-link" href="/archives/2012/11/">十一月 2012</a></li><li class="archive-list-item"><a class="archive-list-link" href="/archives/2012/10/">十月 2012</a></li><li class="archive-list-item"><a class="archive-list-link" href="/archives/2012/07/">七月 2012</a></li><li class="archive-list-item"><a class="archive-list-link" href="/archives/2012/03/">三月 2012</a></li><li class="archive-list-item"><a class="archive-list-link" href="/archives/2012/02/">二月 2012</a></li><li class="archive-list-item"><a class="archive-list-link" href="/archives/2011/10/">十月 2011</a></li><li class="archive-list-item"><a class="archive-list-link" href="/archives/2010/01/">一月 2010</a></li><li class="archive-list-item"><a class="archive-list-link" href="/archives/1970/01/">一月 1970</a></li></ul>
    </div>
  </div>


  
    
  <div class="widget-wrap">
    <h3 class="widget-title">最新文章</h3>
    <div class="widget">
      <ul>
        
          <li>
            <a href="/2016/09/09/space/">空格</a>
          </li>
        
          <li>
            <a href="/2016/07/17/parser/">JavaScript Parser资源总结</a>
          </li>
        
          <li>
            <a href="/2016/06/29/slimerjs/">使用SlimerJS将网页输出为PDF</a>
          </li>
        
          <li>
            <a href="/2016/06/26/code-management/">代码管理</a>
          </li>
        
          <li>
            <a href="/2016/06/18/violet/">violet - 值得一试的写作同步小助手</a>
          </li>
        
      </ul>
    </div>
  </div>

  
</aside>
        
      </div>
      <footer id="footer">
  
  <div class="outer">
    <div id="footer-info" class="inner">
      &copy; 2018 Simon Xu<br>
      Powered by <a href="http://hexo.io/" target="_blank">Hexo</a>
    </div>
  </div>
</footer>
    </div>
    <nav id="mobile-nav">
  
    <a href="/" class="mobile-nav-link">Home</a>
  
    <a href="/archives" class="mobile-nav-link">Archives</a>
  
</nav>
    

<script src="//ajax.googleapis.com/ajax/libs/jquery/2.0.3/jquery.min.js"></script>


  <link rel="stylesheet" href="/fancybox/jquery.fancybox.css">
  <script src="/fancybox/jquery.fancybox.pack.js"></script>


<script src="/js/script.js"></script>



  </div>
</body>
</html>